/**
 * 管理功能相关类型定义
 * 创建时间：2025-09-11
 * 作者：开发团队
 * 目的：定义管理模块数据类型
 */

import type { UserRole, AccountStatus, KeyStatus, SpecialVisitorType, ActionType } from './common'

// 密钥管理相关类型
export interface CryptoKey {
  id: number
  content: string
  created_at: string
  created_by: string
  status: KeyStatus
  expired_at?: string
}

export interface KeyManagementData {
  active_key: CryptoKey | null
  inactive_keys: CryptoKey[]
}

// 特殊访客相关类型
export interface SpecialVisitor {
  id: number
  name: string
  phone: string
  id_card?: string
  type: SpecialVisitorType
  valid_until: string
  remarks?: string
  created_at: string
  updated_at: string
}

export interface SpecialVisitorRequest {
  name: string
  phone: string
  id_card?: string
  type: SpecialVisitorType
  valid_until: string
  remarks?: string
}

export interface SpecialVisitorParams {
  search?: string
  type?: SpecialVisitorType
  page?: number
  size?: number
}

export interface SpecialVisitorImportResult {
  total: number
  success: number
  failed: number
  errors: string[]
}

// 门卫管理相关类型
export interface Guard {
  id: number
  name: string
  username: string
  phone: string
  campus_id: number
  campus_name: string
  status: AccountStatus
  last_login?: string
  created_at: string
}

export interface GuardRequest {
  name: string
  username: string
  password?: string
  phone: string
  campus_id: number
}

export interface GuardParams {
  campus_id?: number
  status?: AccountStatus
  page?: number
  size?: number
}

// 管理员相关类型
export interface Admin {
  id: number
  username: string
  name: string
  role: UserRole
  status: AccountStatus
  permissions: string[]
  created_at: string
}

export interface AdminRequest {
  username: string
  password: string
  name: string
  role: UserRole
  permissions: string[]
}

// 院区相关类型
export interface Campus {
  id: number
  name: string
  address: string
  contact_person: string
  contact_phone: string
  guard_count: number
  created_at: string
}

export interface CampusRequest {
  name: string
  address: string
  contact_person: string
  contact_phone: string
}

// 统计分析相关类型
export interface StatisticsParams {
  start_date: string
  end_date: string
  campus_id?: number
  guard_id?: number
}

export interface StatisticsSummary {
  total_verifications: number
  pass_count: number
  reject_count: number
  special_visitor_count: number
  pass_rate: number
}

export interface DailyTrend {
  date: string
  total: number
  pass: number
  reject: number
}

export interface GuardPerformance {
  guard_id: number
  guard_name: string
  total: number
  pass: number
  reject: number
  efficiency: number
}

export interface SpecialVisitorStats {
  vip: number
  dispute: number
  other: number
}

export interface StatisticsData {
  summary: StatisticsSummary
  daily_trend: DailyTrend[]
  guard_performance: GuardPerformance[]
  special_visitor_stats: SpecialVisitorStats
}

// 审计日志相关类型
export interface AuditLog {
  id: number
  user_id: number
  user_name: string
  action_type: ActionType
  target_type: string
  target_id?: number
  detail: string
  ip_address: string
  created_at: string
}

export interface AuditLogParams {
  start_date?: string
  end_date?: string
  user_id?: number
  action_type?: ActionType
  page?: number
  size?: number
}

// 数据包生成相关类型
export interface DataPackage {
  id: number
  content_types: string[]
  file_size: number
  encryption_status: string
  download_count: number
  created_at: string
  download_url?: string
}

export interface DataPackageRequest {
  content_types: string[]
  encryption?: boolean
}

// 系统监控相关类型
export interface SystemStatus {
  server: {
    cpu_usage: number
    memory_usage: number
    disk_usage: number
    uptime: number
  }
  database: {
    status: string
    connections: number
    size: number
  }
  services: Array<{
    name: string
    status: string
    last_check: string
  }>
}

/**
 * 管理员相关类型定义
 * 创建时间：2025-09-12
 * 作者：开发团队
 * 目的：定义管理员模块数据类型
 */

// 密钥接口
export interface Key {
  id: number
  content: string
  status: 'active' | 'archived' | 'expired'
  created_by: number
  created_at: string
  expired_at?: string
}

// 特殊访客接口
export interface SpecialVisitor {
  id: number
  name: string
  phone: string
  id_card?: string
  type: 'VIP' | '纠纷' | '其他'
  valid_until: string
  remarks?: string
  campus_id?: number
  created_at: string
  updated_at: string
}

// 特殊访客表单接口
export interface SpecialVisitorForm {
  name: string
  phone: string
  id_card?: string
  type: 'VIP' | '纠纷' | '其他'
  valid_until: string
  remarks?: string
}

// 门卫接口
export interface GuardForm {
  username: string
  password: string
  confirmPassword: string
  name: string
  phone?: string
  status: 'active' | 'disabled'
}

// 门卫表单接口
export interface GuardForm {
  username: string
  password: string
  confirmPassword: string
  name: string
  phone?: string
  status: 'active' | 'disabled'
}



// 门卫绩效接口
// (已合并到上方定义)

// 审计日志接口
// (已合并到上方定义)
